<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>Use EJScreen API to get stats on ONLY ONE circular buffer — ejscreenapi1 • EJAM</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/font-awesome-6.4.2/css/all.min.css" rel="stylesheet"><link href="../deps/font-awesome-6.4.2/css/v4-shims.min.css" rel="stylesheet"><script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Use EJScreen API to get stats on ONLY ONE circular buffer — ejscreenapi1"><meta name="description" content="Get EJScreen report results for one circular buffer, as a data.frame"><meta property="og:description" content="Get EJScreen report results for one circular buffer, as a data.frame"><meta property="og:image" content="https://usepa.github.io/EJAM/logo.svg"></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>


    <nav class="navbar navbar-expand-lg fixed-top bg-light" data-bs-theme="light" aria-label="Site navigation"><div class="container">

    <a class="navbar-brand me-2" href="../index.html">EJAM</a>

    <small class="nav-text text-warning me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Released version">2.32.0</small>


    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="active nav-item"><a class="nav-link" href="../reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
  <button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
  <ul class="dropdown-menu" aria-labelledby="dropdown-articles"><li><hr class="dropdown-divider"></li>
    <li><h6 class="dropdown-header" data-toc-skip>Overview for EJAM Users</h6></li>
    <li><a class="dropdown-item" href="../articles/0_whatis.html">What is EJAM</a></li>
    <li><a class="dropdown-item" href="../articles/0_webapp.html">Using EJAM</a></li>
    <li><hr class="dropdown-divider"></li>
    <li><h6 class="dropdown-header" data-toc-skip>For analysts using R</h6></li>
    <li><a class="dropdown-item" href="../articles/1_installing.html">Installing the EJAM R package</a></li>
    <li><a class="dropdown-item" href="../articles/2_quickstart.html">Quick Start Guide</a></li>
    <li><a class="dropdown-item" href="../articles/3_analyzing.html">Basics of Using EJAM for Analysis in RStudio</a></li>
    <li><a class="dropdown-item" href="../articles/4_advanced.html">Advanced Features</a></li>
  </ul></li>
<li class="nav-item"><a class="nav-link" href="../news/index.html">Changelog</a></li>
      </ul><ul class="navbar-nav"><li class="nav-item"><form class="form-inline" role="search">
 <input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="../search.json"></form></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/USEPA/EJAM/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li>
      </ul></div>


  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">
      <img src="../logo.svg" class="logo" alt=""><h1>Use EJScreen API to get stats on ONLY ONE circular buffer</h1>
      <small class="dont-index">Source: <a href="https://github.com/USEPA/EJAM/blob/HEAD/R/ejscreenapi1.R" class="external-link"><code>R/ejscreenapi1.R</code></a></small>
      <div class="d-none name"><code>ejscreenapi1.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>Get EJScreen report results for one circular buffer, as a data.frame</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">ejscreenapi1</span><span class="op">(</span></span>
<span>  <span class="va">lon</span>,</span>
<span>  <span class="va">lat</span>,</span>
<span>  radius <span class="op">=</span> <span class="fl">3</span>,</span>
<span>  unit <span class="op">=</span> <span class="st">"miles"</span>,</span>
<span>  wkid <span class="op">=</span> <span class="fl">4326</span>,</span>
<span>  fips <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  shapefile <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  namestr <span class="op">=</span> <span class="st">""</span>,</span>
<span>  format_report_or_json <span class="op">=</span> <span class="st">"pjson"</span>,</span>
<span>  ipurl <span class="op">=</span> <span class="st">"ejscreen.epa.gov"</span>,</span>
<span>  getstatefromplacename <span class="op">=</span> <span class="cn">TRUE</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>


<dl><dt id="arg-lon">lon<a class="anchor" aria-label="anchor" href="#arg-lon"></a></dt>
<dd><p>Longitude numeric</p></dd>


<dt id="arg-lat">lat<a class="anchor" aria-label="anchor" href="#arg-lat"></a></dt>
<dd><p>Latitude numeric</p></dd>


<dt id="arg-radius">radius<a class="anchor" aria-label="anchor" href="#arg-radius"></a></dt>
<dd><p>radius, in miles, of circular buffer</p></dd>


<dt id="arg-unit">unit<a class="anchor" aria-label="anchor" href="#arg-unit"></a></dt>
<dd><p>miles (default) or kilometers</p></dd>


<dt id="arg-wkid">wkid<a class="anchor" aria-label="anchor" href="#arg-wkid"></a></dt>
<dd><p>optional spatial reference code. https://epsg.io/4326</p></dd>


<dt id="arg-fips">fips<a class="anchor" aria-label="anchor" href="#arg-fips"></a></dt>
<dd><p>if used instead of lon,lat it should be a character FIPS code
(counties, tracts, or blockgroups)</p></dd>


<dt id="arg-shapefile">shapefile<a class="anchor" aria-label="anchor" href="#arg-shapefile"></a></dt>
<dd><p>not implemented</p></dd>


<dt id="arg-namestr">namestr<a class="anchor" aria-label="anchor" href="#arg-namestr"></a></dt>
<dd><p>optional text used on report if fips provided and you want to show this text instead of the FIPS code on the report</p></dd>


<dt id="arg-format-report-or-json">format_report_or_json<a class="anchor" aria-label="anchor" href="#arg-format-report-or-json"></a></dt>
<dd><p>default is "pjson" but could "report" to get URL for a pdf report</p></dd>


<dt id="arg-ipurl">ipurl<a class="anchor" aria-label="anchor" href="#arg-ipurl"></a></dt>
<dd><p>IP or URL start</p></dd>


<dt id="arg-getstatefromplacename">getstatefromplacename<a class="anchor" aria-label="anchor" href="#arg-getstatefromplacename"></a></dt>
<dd><p>set to FALSE if you need the exact output of API and
TRUE if you want to try to extract ST abbrev and statename from the placename field,
which is more likely to be correct than the stateAbbr and stateName fields in the API output.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>Specify a radius and vector of latitude longitude points,
and get for a buffer the population weighted mean value of each raw indicator
like percent low-income, and total population count, and percentiles for those
raw indicator scores, all from EJScreen, as in an EJScreen standard report.</p>
<p>Note that this API is fairly slow, so it is fine for 10 sites, but not large numbers.</p>
<p>Relies on <code><a href="ejscreenRESTbroker.html">ejscreenRESTbroker()</a></code> for the actual request via API,
and <code><a href="ejscreenRESTbroker2table.html">ejscreenRESTbroker2table()</a></code> to format it and handle errors.</p>
<p>It essentially does this: ejscreenRESTbroker2table(ejscreenRESTbroker())
And then it adds the columns  "pdf_report" and "pdf_acs_report"</p>
<p>It returns a 1-row data.frame</p>
<p>and makes relevant columns values numeric,
and converts text like 45% to the number 45.</p>
<p>It also drops redundant columns where the same numbers had been returned from API
using the normal name and a synonym name, as with TOTALPOP and "totalPop"</p>
<p>See  (https://www.epa.gov/ejscreen/ejscreen-api)</p>
    </div>
    <div class="section level2">
    <h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
    <div class="dont-index"><p><code><a href="ejscreenit.html">ejscreenit()</a></code> <code><a href="ejscreenapi_plus.html">ejscreenapi_plus()</a></code> <code><a href="ejscreenapi.html">ejscreenapi()</a></code>
that uses <code>ejscreenapi1()</code> and <code><a href="ejscreenRESTbroker.html">ejscreenRESTbroker()</a></code>  and <code><a href="ejscreenRESTbroker2table.html">ejscreenRESTbroker2table()</a></code></p></div>
    </div>

    <div class="section level2">
    <h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span> </span>
<span> <span class="kw">if</span> <span class="op">(</span><span class="cn">FALSE</span><span class="op">)</span> <span class="op">{</span> <span class="co"># \dontrun{</span></span>
<span> <span class="co"># Specify size of buffer circle and pick random points as example data</span></span>
<span> <span class="va">myradius</span> <span class="op">&lt;-</span> <span class="fl">1</span></span>
<span> <span class="va">pts</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/structure.html" class="external-link">structure</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>lon <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="op">-</span><span class="fl">96.4798957</span>, <span class="op">-</span><span class="fl">111.7674343</span>, <span class="op">-</span><span class="fl">75.4173589</span>, </span>
<span> <span class="op">-</span><span class="fl">95.9573172</span>, <span class="op">-</span><span class="fl">87.8402677</span>, <span class="op">-</span><span class="fl">77.9996191</span>, <span class="op">-</span><span class="fl">73.920702</span>, <span class="op">-</span><span class="fl">79.9545638</span>, </span>
<span> <span class="op">-</span><span class="fl">76.0638877</span>, <span class="op">-</span><span class="fl">114.9881473</span><span class="op">)</span>, lat <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">31.782716</span>, <span class="fl">33.7522735</span>, <span class="fl">39.8697972</span>, </span>
<span> <span class="fl">33.2522474</span>, <span class="fl">41.9763992</span>, <span class="fl">38.4661259</span>, <span class="fl">41.2940801</span>, <span class="fl">32.8099327</span>, <span class="fl">40.9888266</span>, </span>
<span> <span class="fl">36.0043628</span><span class="op">)</span>, id <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">10</span><span class="op">)</span>, row.names <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="cn">NA</span>, <span class="op">-</span><span class="fl">10L</span><span class="op">)</span>, class <span class="op">=</span> <span class="st">"data.frame"</span><span class="op">)</span></span>
<span> <span class="va">out1</span> <span class="op">&lt;-</span> <span class="fu">ejscreenapi1</span><span class="op">(</span>lon <span class="op">=</span> <span class="va">pts</span><span class="op">$</span><span class="va">lon</span><span class="op">[</span><span class="fl">1</span><span class="op">]</span>, lat<span class="op">=</span><span class="va">pts</span><span class="op">$</span><span class="va">lat</span><span class="op">[</span><span class="fl">1</span><span class="op">]</span>, radius <span class="op">=</span> <span class="va">myradius</span><span class="op">)</span></span>
<span> <span class="fu"><a href="https://rdrr.io/r/base/t.html" class="external-link">t</a></span><span class="op">(</span><span class="va">out1</span><span class="op">)</span></span>
<span> <span class="co">#out &lt;- ejscreenapi(lon=pts$lon, lat=pts$lat, radius = myradius)</span></span>
<span> <span class="co">#t(out[1:2,])</span></span>
<span> <span class="op">}</span> <span class="co"># }</span></span>
<span> </span></code></pre></div>
    </div>
  </main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
    </nav></aside></div>


    <footer><div class="pkgdown-footer-left">
  <p>US EPA 2024</p>
</div>

<div class="pkgdown-footer-right">
  <p>EJAM Version 2.32.0</p>
</div>

    </footer></div>





  </body></html>

